﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace Hinacom.Scheduler.Configuration
{
    /// <summary>
    /// 任务类型配置。
    /// </summary>
    public class JobTypeConfiguration : ConfigurationElement
    {
        /// <summary>
        /// 任务类型的名称。
        /// </summary>
        [ConfigurationProperty("name", IsRequired = true)]
        public string Name
        {
            get { return this["name"] as string; }
        }
        /// <summary>
        /// 任务类型对应的SchedulerJob实现类。格式：{Type Full Name}, {Assembly Name}。
        /// </summary>
        [ConfigurationProperty("type", IsRequired = true)]
        public string Type
        {
            get { return this["type"] as string; }
        }
        public override string ToString()
        {
            return Name;
        }
    }
    /// <summary>
    /// 任务类型配置集合。
    /// </summary>
    public class JobTypeConfigurationCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new JobTypeConfiguration();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((JobTypeConfiguration)element).Name;
        }

        public JobTypeConfiguration Get(string name)
        {
            return BaseGet(name) as JobTypeConfiguration;
        }
        
    }


}
